package controllers;

import models.Picture;
import models.Place;
import models.Telephone;
import play.data.Upload;
import play.mvc.Controller;
import util.FileUtil;

public class PlaceController {
	
	protected static void savePlace(Place place, Telephone telephone, Upload picture) {
		if (picture != null) {
			Picture newPicture = new Picture();
			newPicture.setMimeType(FileUtil.getExtensaoArquivo(picture.asFile()));
			newPicture.setData(picture.asBytes());
			newPicture.save();
			place.getPictures().add(newPicture);
		}
		telephone.save();
		place.getTelephones().add(telephone);
		place.save();
	}

}
